using System.Collections.Generic;
using UnityEngine;

public class WeaponItem : MonoBehaviour
{
	public weapontype curtype;

	private int CurPlane;

	public UILabel[] scrollname;

	public UISprite[] scrollsprite;

	public UISprite[] scrolllock;

	public UISprite[] selectFlag;

	public UIEventListener[] itembtn;

	public UIEventListener leftbtn;

	public UIEventListener rightbtn;

	public UISprite leftflag;

	public UISprite rightflag;

	public UISprite showpic;

	public UISprite equipedflag;

	public TweenScale equipedAnima;

	public UISprite equipedbtnflag;

	public UILabel levellabel;

	public UISprite[] levelflag;

	public UILabel weaponname;

	public UILabel[] Attinfolabel;

	public UISprite[] Attslider;

	private bool showslider;

	private float slidertime;

	public float[] attdes;

	public UISprite[] forstars;

	public UIWidget forbidewi;

	public UIWidget unlockwi;

	public UIWidget lockwi;

	public UIWidget upgradewi;

	public UIEventListener unlockbtn;

	public UIEventListener equipedbtn;

	public UIEventListener upgradebtn;

	public UIEventListener piecebtn;

	public PieceData curpiece;

	public UILabel forbidenum;

	public UISprite lockflag;

	public UILabel locknum;

	public UILabel upgradenum;

	public int equipednum;

	public weaponlock[] CurweaponLockinfo;

	public List<weaopn_armour> armourdata;

	public List<weapon_gun> gunmissiledata;

	public List<weapon_miss> YDDdata;

	public int shownum;

	public UIScrollBar planescroll;

	public UIScrollView planescrollview;

	private bool scrollmoveflag;

	private float starttime;

	private float intaltime;

	private float endval;

	private float scrollrate;

	private float scrollstep = 0.3f;

	private int[] weaponPicSp = new int[10]
	{
		1,
		2,
		3,
		4,
		3,
		5,
		4,
		6,
		5,
		6
	};

	private float[] eightratio = new float[9]
	{
		0.3f,
		0.4f,
		0.5f,
		0.56f,
		0.62f,
		0.7f,
		0.8f,
		0.9f,
		1f
	};

	public UIWidget salewi;

	public UIEventListener salebtn;

	private Color bluecolor = Color.white;

	private int preshow = -1;

	private void Start()
	{
		for (int i = 0; i < itembtn.Length; i++)
		{
			itembtn[i].onClick = onclickitemBtn;
		}
		if (leftbtn != null)
		{
			leftbtn.onClick = OnClickleftBtn;
			rightbtn.onClick = OnClickrightBtn;
		}
		unlockbtn.onClick = OnClickUnlockBtn;
		upgradebtn.onClick = OnClickUpgradeBtn;
		equipedbtn.onClick = OnClickequipedBtn;
		piecebtn.onClick = OnClickpiecebtn;
		salebtn.onClick = OnClickOnSaleBtn;
	}

	public void init_ui_info()
	{
		MenuPlayerprefs.instance.readStoreData();
		switch (curtype)
		{
			case weapontype.armour:
				equipednum = MenuPlayerprefs.instance.DS_Plane[CurPlane].armourtype;
				CurweaponLockinfo = MenuPlayerprefs.instance.armourlock;
				armourdata = MenuDataController.instance.ArmourData;
				if (equipednum == -1)
				{
					shownum = 0;
				}
				else
				{
					shownum = equipednum;
				}
				armourscrollshow();
				armourinfoshow();
				break;
			case weapontype.gun:
				equipednum = MenuPlayerprefs.instance.DS_Plane[CurPlane].guntype;
				CurweaponLockinfo = MenuPlayerprefs.instance.gunlock;
				gunmissiledata = MenuDataController.instance.MachineGunData;
				if (equipednum == -1)
				{
					shownum = 0;
				}
				else
				{
					shownum = equipednum;
				}
				gunscrollshow();
				guninfoshow();
				break;
			case weapontype.longrange:
				equipednum = MenuPlayerprefs.instance.DS_Plane[CurPlane].longtype;
				CurweaponLockinfo = MenuPlayerprefs.instance.longlock;
				gunmissiledata = MenuDataController.instance.longmissileData;
				if (equipednum == -1)
				{
					shownum = 0;
				}
				else
				{
					shownum = equipednum;
				}
				gunscrollshow();
				guninfoshow();
				break;
			case weapontype.multiple:
				equipednum = MenuPlayerprefs.instance.DS_Plane[CurPlane].multipletype;
				CurweaponLockinfo = MenuPlayerprefs.instance.multiplelock;
				gunmissiledata = MenuDataController.instance.MultipleData;
				if (equipednum == -1)
				{
					shownum = 0;
				}
				else
				{
					shownum = equipednum;
				}
				gunscrollshow();
				guninfoshow();
				break;
			case weapontype.miss:
				equipednum = MenuPlayerprefs.instance.DS_Plane[CurPlane].misstype;
				CurweaponLockinfo = MenuPlayerprefs.instance.misslock;
				YDDdata = MenuDataController.instance.YoudaodanData;
				if (equipednum == -1)
				{
					shownum = 0;
				}
				else
				{
					shownum = equipednum;
				}
				missscrollshow();
				missinfoshow();
				break;
		}
		preshow = shownum;
		for (int i = 0; i < Attslider.Length; i++)
		{
			Attslider[i].fillAmount = 0f;
		}
	}

	public void resetScroll()
	{
		if (planescroll != null)
		{
			if (curtype == weapontype.gun)
			{
				planescroll.value = (float)(shownum - 2) / 7f;
			}
			else
			{
				planescroll.value = (float)(shownum - 2) / 5f;
			}
		}
	}

	public void missscrollshow()
	{
		for (int i = 0; i < YDDdata.Count; i++)
		{
			scrollname[i].text = YDDdata[i].name;
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
			if (YDDdata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				if (CurweaponLockinfo[i].islock == 1)
				{
					scrolllock[i].enabled = true;
				}
				else
				{
					scrolllock[i].enabled = false;
				}
			}
			else
			{
				scrolllock[i].enabled = false;
			}
		}
	}

	public void showscroll_YDD()
	{
		for (int i = 0; i < YDDdata.Count; i++)
		{
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
		}
	}

	public void missinfoshow()
	{
		for (int i = 0; i < YDDdata.Count; i++)
		{
			if (i == shownum)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuKuang";
				scrollname[i].color = Color.black;
				continue;
			}
			scrollname[i].color = bluecolor;
			if (YDDdata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiu";
			}
			else
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuHui";
			}
		}
		showpic.spriteName = "ZB_youDaoDan_0" + weaponPicSp[shownum];
		if (shownum == equipednum)
		{
			equipedflag.enabled = true;
			equipedbtnflag.spriteName = "JS_anNiuHui";
		}
		else
		{
			equipedflag.enabled = false;
			equipedbtnflag.spriteName = "JS_anNiu";
		}
		weaponname.text = YDDdata[shownum].name;
		Attinfolabel[0].text = YDDdata[shownum].num + "";
		upgradewi.alpha = 0f;
		upgradewi.gameObject.SetActive(false);
		if (YDDdata[shownum].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
		{
			forbidewi.alpha = 0f;
			forbidewi.gameObject.SetActive(false);
			if (CurweaponLockinfo[shownum].islock == 1)
			{
				unlockwi.alpha = 0f;
				unlockwi.gameObject.SetActive(false);
				lockwi.alpha = 1f;
				lockwi.gameObject.SetActive(true);
				if (MenuPlayerprefs.instance.saleid == 2 && shownum == 0)
				{
					salewi.alpha = 1f;
					salewi.gameObject.SetActive(true);
				}
				else
				{
					salewi.alpha = 0f;
					salewi.gameObject.SetActive(false);
				}
				switch (YDDdata[shownum].unlocktype)
				{
					case 0:
						lockflag.spriteName = "GY_zuanShi_01";
						lockflag.SetDimensions(32, 24);
						locknum.text = string.Empty + YDDdata[shownum].unlocknum;
						break;
					case 1:
						lockflag.spriteName = "CZ_jinBi_02";
						lockflag.SetDimensions(32, 25);
						locknum.text = string.Empty + YDDdata[shownum].unlocknum;
						break;
					case 2:
						curpiece = MenuDataController.instance.Getpiece(YDDdata[shownum].id);
						lockflag.spriteName = "GY_SP_" + curpiece.id;
						lockflag.SetDimensions(36, 33);
						locknum.text = MenuPlayerprefs.instance.piecenum[curpiece.id] + "/" + YDDdata[shownum].unlocknum;
						break;
				}
			}
			else
			{
				unlockwi.alpha = 1f;
				unlockwi.gameObject.SetActive(true);
				lockwi.alpha = 0f;
				lockwi.gameObject.SetActive(false);
				salewi.alpha = 0f;
				salewi.gameObject.SetActive(false);
			}
		}
		else
		{
			forbidewi.alpha = 1f;
			forbidewi.gameObject.SetActive(true);
			unlockwi.alpha = 0f;
			unlockwi.gameObject.SetActive(false);
			lockwi.alpha = 0f;
			lockwi.gameObject.SetActive(false);
			salewi.alpha = 0f;
			salewi.gameObject.SetActive(false);
			forbidenum.text = string.Empty + YDDdata[shownum].planelevel;
		}
		show_star(YDDdata[shownum].star);
	}

	public void gunscrollshow()
	{
		for (int i = 0; i < gunmissiledata.Count; i++)
		{
			scrollname[i].text = gunmissiledata[i].name;
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
			if (gunmissiledata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				if (CurweaponLockinfo[i].islock == 1)
				{
					scrolllock[i].enabled = true;
				}
				else
				{
					scrolllock[i].enabled = false;
				}
			}
			else
			{
				scrolllock[i].enabled = false;
			}
		}
	}

	public void showscroll_gun()
	{
		for (int i = 0; i < gunmissiledata.Count; i++)
		{
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
		}
	}

	public void guninfoshow()
	{
		for (int i = 0; i < gunmissiledata.Count; i++)
		{
			if (i == shownum)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuKuang";
				scrollname[i].color = Color.black;
				continue;
			}
			scrollname[i].color = bluecolor;
			if (gunmissiledata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiu";
			}
			else
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuHui";
			}
		}
		switch (curtype)
		{
			case weapontype.gun:
				showpic.spriteName = "ZB_jiQiang_0" + weaponPicSp[shownum];
				break;
			case weapontype.longrange:
				showpic.spriteName = "ZB_danMuBiaoDaoDan_0" + weaponPicSp[shownum];
				break;
			case weapontype.multiple:
				showpic.spriteName = "ZB_duoMuBiaoDaoDan_0" + weaponPicSp[shownum];
				break;
		}
		if (shownum == equipednum)
		{
			equipedflag.enabled = true;
			equipedbtnflag.spriteName = "JS_anNiuHui";
		}
		else
		{
			equipedflag.enabled = false;
			equipedbtnflag.spriteName = "JS_anNiu";
		}
		levellabel.text = "Lv." + (CurweaponLockinfo[shownum].curlv + 1);
		for (int j = 0; j < levelflag.Length; j++)
		{
			if (CurweaponLockinfo[shownum].curlv >= j)
			{
				levelflag[j].enabled = true;
			}
			else
			{
				levelflag[j].enabled = false;
			}
		}
		weaponname.text = gunmissiledata[shownum].name;
		if (gunmissiledata[shownum].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
		{
			forbidewi.alpha = 0f;
			forbidewi.gameObject.SetActive(false);
			if (CurweaponLockinfo[shownum].islock == 1)
			{
				Attinfolabel[0].text = gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] + "";
				Attinfolabel[1].text = gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] + "";
				Attinfolabel[2].text = gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] + "";
				Attinfolabel[3].text = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] + "";
				upgradewi.alpha = 0f;
				upgradewi.gameObject.SetActive(false);
				unlockwi.alpha = 0f;
				unlockwi.gameObject.SetActive(false);
				lockwi.alpha = 1f;
				lockwi.gameObject.SetActive(true);
				switch (gunmissiledata[shownum].unlocktype)
				{
					case 0:
						lockflag.spriteName = "GY_zuanShi_01";
						lockflag.SetDimensions(32, 24);
						locknum.text = string.Empty + gunmissiledata[shownum].unlocknum;
						break;
					case 1:
						lockflag.spriteName = "CZ_jinBi_02";
						lockflag.SetDimensions(32, 25);
						locknum.text = string.Empty + gunmissiledata[shownum].unlocknum;
						break;
					case 2:
						curpiece = MenuDataController.instance.Getpiece(gunmissiledata[shownum].id);
						lockflag.spriteName = "GY_SP_" + curpiece.id;
						lockflag.SetDimensions(36, 33);
						locknum.text = MenuPlayerprefs.instance.piecenum[curpiece.id] + "/" + gunmissiledata[shownum].unlocknum;
						break;
				}
				switch (curtype)
				{
					case weapontype.gun:
						if (MenuPlayerprefs.instance.saleid == 2 && shownum == 4)
						{
							salewi.alpha = 1f;
							salewi.gameObject.SetActive(true);
						}
						else
						{
							salewi.alpha = 0f;
							salewi.gameObject.SetActive(false);
						}
						break;
					case weapontype.longrange:
						if ((MenuPlayerprefs.instance.saleid == 0 && shownum == 1) || (MenuPlayerprefs.instance.saleid == 2 && shownum == 3))
						{
							salewi.alpha = 1f;
							salewi.gameObject.SetActive(true);
						}
						else
						{
							salewi.alpha = 0f;
							salewi.gameObject.SetActive(false);
						}
						break;
					case weapontype.multiple:
						if (MenuPlayerprefs.instance.saleid == 2 && shownum == 3)
						{
							salewi.alpha = 1f;
							salewi.gameObject.SetActive(true);
						}
						else
						{
							salewi.alpha = 0f;
							salewi.gameObject.SetActive(false);
						}
						break;
				}
			}
			else
			{
				if (CurweaponLockinfo[shownum].curlv == 9)
				{
					Attinfolabel[0].text = gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] + "";
					Attinfolabel[1].text = gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] + "";
					Attinfolabel[2].text = gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] + "";
					Attinfolabel[3].text = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] + "";
					upgradewi.alpha = 0f;
					upgradewi.gameObject.SetActive(false);
				}
				else
				{
					if (gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] != gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[0].text = gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] + " >> " + gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[0].text = "" + gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] + "";
					}
					if (gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] != gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[1].text = "" + gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] + " >> " + gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[1].text = "" + gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] + "";
					}
					if (gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] != gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[2].text = "" + gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] + " >> " + gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[2].text = "" + gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] + "";
					}
					if (gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] != gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[3].text = "" + gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] + " >> " + gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[3].text = "" + gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] + "";
					}
					upgradewi.alpha = 1f;
					upgradewi.gameObject.SetActive(true);
				}
				unlockwi.alpha = 1f;
				unlockwi.gameObject.SetActive(true);
				lockwi.alpha = 0f;
				lockwi.gameObject.SetActive(false);
				salewi.alpha = 0f;
				salewi.gameObject.SetActive(false);
				if (CurweaponLockinfo[shownum].curlv < 9)
				{
					upgradenum.text = string.Empty + gunmissiledata[shownum].levelupgold[CurweaponLockinfo[shownum].curlv + 1];
				}
			}
		}
		else
		{
			Attinfolabel[0].text = gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv] + "";
			Attinfolabel[1].text = gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv] + "";
			Attinfolabel[2].text = gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] + "";
			Attinfolabel[3].text = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] + "";
			upgradewi.alpha = 0f;
			upgradewi.gameObject.SetActive(false);
			forbidewi.alpha = 1f;
			forbidewi.gameObject.SetActive(true);
			unlockwi.alpha = 0f;
			unlockwi.gameObject.SetActive(false);
			lockwi.alpha = 0f;
			lockwi.gameObject.SetActive(false);
			salewi.alpha = 0f;
			salewi.gameObject.SetActive(false);
			forbidenum.text = string.Empty + gunmissiledata[shownum].planelevel;
		}
		switch (curtype)
		{
			case weapontype.gun:
				attdes[0] = 0.3f + 0.00112903223f * (float)gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv];
				attdes[1] = 0.2f + 0.0009411765f * (float)gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv];
				attdes[2] = (float)gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] / 90f;
				attdes[3] = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] / 6f;
				break;
			case weapontype.longrange:
				attdes[0] = 0.2f + 5.71428573E-05f * (float)gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv];
				attdes[1] = 0.3f + 0.000875f * (float)gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv];
				attdes[2] = (float)gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] / 5f;
				attdes[3] = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] / 16f;
				break;
			case weapontype.multiple:
				attdes[0] = 0.25f + 5.769231E-05f * (float)gunmissiledata[shownum].att[CurweaponLockinfo[shownum].curlv];
				attdes[1] = 0.35f + 0.0011818182f * (float)gunmissiledata[shownum].pen[CurweaponLockinfo[shownum].curlv];
				attdes[2] = (float)gunmissiledata[shownum].maxnum[CurweaponLockinfo[shownum].curlv] / 8f;
				attdes[3] = gunmissiledata[shownum].time[CurweaponLockinfo[shownum].curlv] / 16f;
				break;
		}
		showslider = true;
		slidertime = 0f;
		show_star(gunmissiledata[shownum].star);
	}

	public void armourscrollshow()
	{
		for (int i = 0; i < armourdata.Count; i++)
		{
			scrollname[i].text = armourdata[i].name;
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
			if (armourdata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				if (CurweaponLockinfo[i].islock == 1)
				{
					scrolllock[i].enabled = true;
				}
				else
				{
					scrolllock[i].enabled = false;
				}
			}
			else
			{
				scrolllock[i].enabled = false;
			}
		}
	}

	public void showscroll_armour()
	{
		for (int i = 0; i < armourdata.Count; i++)
		{
			if (i == equipednum)
			{
				selectFlag[i].enabled = true;
			}
			else
			{
				selectFlag[i].enabled = false;
			}
		}
	}

	public void armourinfoshow()
	{
		for (int i = 0; i < armourdata.Count; i++)
		{
			if (i == shownum)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuKuang";
				scrollname[i].color = Color.black;
				continue;
			}
			scrollname[i].color = bluecolor;
			if (armourdata[i].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiu";
			}
			else
			{
				scrollsprite[i].spriteName = "GY_huaDongTiaoAnNiuHui";
			}
		}
		showpic.spriteName = "ZB_zhuangJia_0" + weaponPicSp[shownum];
		if (shownum == equipednum)
		{
			equipedflag.enabled = true;
			equipedbtnflag.spriteName = "JS_anNiuHui";
		}
		else
		{
			equipedflag.enabled = false;
			equipedbtnflag.spriteName = "JS_anNiu";
		}
		levellabel.text = "Lv." + (CurweaponLockinfo[shownum].curlv + 1);
		for (int j = 0; j < levelflag.Length; j++)
		{
			if (CurweaponLockinfo[shownum].curlv >= j)
			{
				levelflag[j].enabled = true;
			}
			else
			{
				levelflag[j].enabled = false;
			}
		}
		weaponname.text = armourdata[shownum].name;
		if (armourdata[shownum].planelevel <= MenuDataController.instance.PlaneData[CurPlane].level)
		{
			forbidewi.alpha = 0f;
			forbidewi.gameObject.SetActive(false);
			if (CurweaponLockinfo[shownum].islock == 1)
			{
				Attinfolabel[0].text = armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] + "";
				Attinfolabel[1].text = armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] + "";
				upgradewi.alpha = 0f;
				upgradewi.gameObject.SetActive(false);
				unlockwi.alpha = 0f;
				unlockwi.gameObject.SetActive(false);
				lockwi.alpha = 1f;
				lockwi.gameObject.SetActive(true);
				if ((MenuPlayerprefs.instance.saleid == 0 && shownum == 1) || (MenuPlayerprefs.instance.saleid == 2 && shownum == 4))
				{
					salewi.alpha = 1f;
					salewi.gameObject.SetActive(true);
				}
				else
				{
					salewi.alpha = 0f;
					salewi.gameObject.SetActive(false);
				}
				switch (armourdata[shownum].unlocktype)
				{
					case 0:
						lockflag.spriteName = "GY_zuanShi_01";
						lockflag.SetDimensions(32, 24);
						locknum.text = string.Empty + armourdata[shownum].unlocknum;
						break;
					case 1:
						lockflag.spriteName = "CZ_jinBi_02";
						lockflag.SetDimensions(32, 25);
						locknum.text = string.Empty + armourdata[shownum].unlocknum;
						break;
					case 2:
						curpiece = MenuDataController.instance.Getpiece(armourdata[shownum].id);
						lockflag.spriteName = "GY_SP_" + curpiece.id;
						lockflag.SetDimensions(36, 33);
						locknum.text = MenuPlayerprefs.instance.piecenum[curpiece.id] + "/" + armourdata[shownum].unlocknum;
						break;
				}
			}
			else
			{
				if (CurweaponLockinfo[shownum].curlv == 9)
				{
					Attinfolabel[0].text = armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] + "";
					Attinfolabel[1].text = armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] + "";
					upgradewi.alpha = 0f;
					upgradewi.gameObject.SetActive(false);
				}
				else
				{
					if (armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] != armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[0].text = armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] + " >> " + armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[0].text = armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] + "";
					}
					if (armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] != armourdata[shownum].def[CurweaponLockinfo[shownum].curlv + 1])
					{
						Attinfolabel[1].text = armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] + " >> " + armourdata[shownum].def[CurweaponLockinfo[shownum].curlv + 1] + "";
					}
					else
					{
						Attinfolabel[1].text = armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] + "";
					}
					upgradewi.alpha = 1f;
					upgradewi.gameObject.SetActive(true);
				}
				unlockwi.alpha = 1f;
				unlockwi.gameObject.SetActive(true);
				lockwi.alpha = 0f;
				lockwi.gameObject.SetActive(false);
				salewi.alpha = 0f;
				salewi.gameObject.SetActive(false);
				if (CurweaponLockinfo[shownum].curlv < 9)
				{
					upgradenum.text = string.Empty + armourdata[shownum].levelupgold[CurweaponLockinfo[shownum].curlv + 1];
				}
			}
		}
		else
		{
			Attinfolabel[0].text = armourdata[shownum].hp[CurweaponLockinfo[shownum].curlv] + "";
			Attinfolabel[1].text = armourdata[shownum].def[CurweaponLockinfo[shownum].curlv] + "";
			upgradewi.alpha = 0f;
			upgradewi.gameObject.SetActive(false);
			forbidewi.alpha = 1f;
			forbidewi.gameObject.SetActive(true);
			unlockwi.alpha = 0f;
			unlockwi.gameObject.SetActive(false);
			lockwi.alpha = 0f;
			lockwi.gameObject.SetActive(false);
			salewi.alpha = 0f;
			salewi.gameObject.SetActive(false);
			forbidenum.text = string.Empty + armourdata[shownum].planelevel;
		}
		attdes[0] = eightratio[shownum] + (eightratio[shownum + 1] - eightratio[shownum]) * 0.1f * (float)CurweaponLockinfo[shownum].curlv;
		attdes[1] = 0.2f + 0.00117647054f * (float)armourdata[shownum].def[CurweaponLockinfo[shownum].curlv];
		showslider = true;
		slidertime = 0f;
		show_star(armourdata[shownum].star);
	}

	public void show_star(float star)
	{
		int num = (int)(star * 10f);
		int num2 = num / 10;
		bool flag = (num % 10 != 0) ? true : false;
		for (int i = 0; i < forstars.Length; i++)
		{
			if (i < num2)
			{
				forstars[i].spriteName = "JS_xing2";
				forstars[i].enabled = true;
			}
			else if (i == num2 && flag)
			{
				forstars[i].spriteName = "JS_banXing";
				forstars[i].enabled = true;
			}
			else
			{
				forstars[i].enabled = false;
			}
		}
	}

	private void Update()
	{
		if (scrollmoveflag)
		{
			if (planescrollview.isbepress)
			{
				scrollmoveflag = false;
				return;
			}
			if (Time.time - starttime < intaltime)
			{
				planescroll.value += Time.deltaTime * scrollrate;
				if (Mathf.Abs(planescroll.value - endval) > scrollstep)
				{
					scrollmoveflag = false;
				}
			}
			else
			{
				planescroll.value = endval;
				scrollmoveflag = false;
			}
		}
		if (showslider)
		{
			for (int i = 0; i < Attslider.Length; i++)
			{
				Attslider[i].fillAmount = Mathf.Lerp(Attslider[i].fillAmount, attdes[i], Time.deltaTime * 4f);
			}
			slidertime += Time.deltaTime;
			if (slidertime >= 2f)
			{
				showslider = false;
				slidertime = 0f;
			}
		}
	}

	public void OnClickequipedBtn(GameObject btn)
	{
		switch (curtype)
		{
			case weapontype.armour:
				if (equipednum != shownum)
				{
					equipednum = shownum;
					showscroll_armour();
					equipedflag.enabled = true;
					equipedbtnflag.spriteName = "JS_anNiuHui";
					equipedAnima.ResetToBeginning();
					equipedAnima.PlayForward();
					MenuPlayerprefs.instance.save_plane_armour(CurPlane, shownum);
				}
				break;
			case weapontype.gun:
				if (equipednum != shownum)
				{
					equipednum = shownum;
					showscroll_gun();
					equipedflag.enabled = true;
					equipedbtnflag.spriteName = "JS_anNiuHui";
					equipedAnima.ResetToBeginning();
					equipedAnima.PlayForward();
					MenuPlayerprefs.instance.save_plane_gun(CurPlane, shownum);
				}
				break;
			case weapontype.longrange:
				if (equipednum != shownum)
				{
					equipednum = shownum;
					showscroll_gun();
					equipedflag.enabled = true;
					equipedbtnflag.spriteName = "JS_anNiuHui";
					equipedAnima.ResetToBeginning();
					equipedAnima.PlayForward();
					MenuPlayerprefs.instance.save_plane_long(CurPlane, shownum);
				}
				break;
			case weapontype.multiple:
				if (equipednum != shownum)
				{
					equipednum = shownum;
					showscroll_gun();
					equipedflag.enabled = true;
					equipedbtnflag.spriteName = "JS_anNiuHui";
					equipedAnima.ResetToBeginning();
					equipedAnima.PlayForward();
					MenuPlayerprefs.instance.save_plane_multiple(CurPlane, shownum);
				}
				break;
			case weapontype.miss:
				if (equipednum != shownum)
				{
					equipednum = shownum;
					showscroll_YDD();
					equipedflag.enabled = true;
					equipedbtnflag.spriteName = "JS_anNiuHui";
					equipedAnima.ResetToBeginning();
					equipedAnima.PlayForward();
					MenuPlayerprefs.instance.save_plane_miss(CurPlane, shownum);
				}
				break;
		}
		if (equipednum != shownum && btn != null)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_equiped, 0f);
		}
	}

	public void OnClickUpgradeBtn(GameObject btn)
	{
		switch (curtype)
		{
			case weapontype.miss:
				break;
			case weapontype.armour:
				armourupgrade();
				break;
			case weapontype.gun:
				gunupgrade();
				break;
			case weapontype.longrange:
				gunupgrade();
				break;
			case weapontype.multiple:
				gunupgrade();
				break;
		}
	}

	public void armourupgrade()
	{
		if (MenuPlayerprefs.instance.DecMoney(armourdata[shownum].levelupgold[CurweaponLockinfo[shownum].curlv + 1]))
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
			CurweaponLockinfo[shownum].curlv++;
			MenuPlayerprefs.instance.save_weapon_armour(shownum, CurweaponLockinfo[shownum]);
			armourinfoshow();
			MenuPlayerprefs.instance.savedailytask(3);
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
			MenuUIController.instance.enable_chargeui(0);
		}
	}

	public void gunupgrade()
	{
		if (MenuPlayerprefs.instance.DecMoney(gunmissiledata[shownum].levelupgold[CurweaponLockinfo[shownum].curlv + 1]))
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
			CurweaponLockinfo[shownum].curlv++;
			if (curtype == weapontype.gun)
			{
				MenuPlayerprefs.instance.save_weapon_gun(shownum, CurweaponLockinfo[shownum]);
			}
			else if (curtype == weapontype.longrange)
			{
				MenuPlayerprefs.instance.save_weapon_long(shownum, CurweaponLockinfo[shownum]);
			}
			else
			{
				MenuPlayerprefs.instance.save_weapon_multiple(shownum, CurweaponLockinfo[shownum]);
			}
			guninfoshow();
			MenuPlayerprefs.instance.savedailytask(3);
		}
		else
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
			MenuUIController.instance.enable_chargeui(0);
		}
	}

	public void OnClickUnlockBtn(GameObject btn)
	{
		switch (curtype)
		{
			case weapontype.armour:
				armourunlock();
				break;
			case weapontype.gun:
				gununlock();
				break;
			case weapontype.longrange:
				gununlock();
				break;
			case weapontype.multiple:
				gununlock();
				break;
			case weapontype.miss:
				missunlock();
				break;
		}
	}

	public void missunlock()
	{
		switch (YDDdata[shownum].unlocktype)
		{
			case 0:
				if (MenuPlayerprefs.instance.DecDiamond(YDDdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.save_weapon_miss(shownum, CurweaponLockinfo[shownum]);
					scrolllock[shownum].enabled = false;
					missinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(1);
				}
				break;
			case 1:
				if (MenuPlayerprefs.instance.DecMoney(YDDdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.save_weapon_miss(shownum, CurweaponLockinfo[shownum]);
					scrolllock[shownum].enabled = false;
					missinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(0);
				}
				break;
			case 2:
				curpiece = MenuDataController.instance.Getpiece(YDDdata[shownum].id);
				if (MenuPlayerprefs.instance.DecPiece(curpiece.id, YDDdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.save_weapon_miss(shownum, CurweaponLockinfo[shownum]);
					MenuPlayerprefs.instance.savepieceflag(curpiece.id);
					scrolllock[shownum].enabled = false;
					missinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
					MenuUIController.instance.enable_getpieceui(curpiece);
				}
				break;
		}
	}

	public void gununlock()
	{
		switch (gunmissiledata[shownum].unlocktype)
		{
			case 0:
				if (MenuPlayerprefs.instance.DecDiamond(gunmissiledata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					if (curtype == weapontype.gun)
					{
						MenuPlayerprefs.instance.save_weapon_gun(shownum, CurweaponLockinfo[shownum]);
					}
					else if (curtype == weapontype.longrange)
					{
						MenuPlayerprefs.instance.save_weapon_long(shownum, CurweaponLockinfo[shownum]);
					}
					else
					{
						MenuPlayerprefs.instance.save_weapon_multiple(shownum, CurweaponLockinfo[shownum]);
					}
					scrolllock[shownum].enabled = false;
					guninfoshow();
					saveachi_gun();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(1);
				}
				break;
			case 1:
				if (MenuPlayerprefs.instance.DecMoney(gunmissiledata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					if (curtype == weapontype.gun)
					{
						MenuPlayerprefs.instance.save_weapon_gun(shownum, CurweaponLockinfo[shownum]);
					}
					else if (curtype == weapontype.longrange)
					{
						MenuPlayerprefs.instance.save_weapon_long(shownum, CurweaponLockinfo[shownum]);
					}
					else
					{
						MenuPlayerprefs.instance.save_weapon_multiple(shownum, CurweaponLockinfo[shownum]);
					}
					scrolllock[shownum].enabled = false;
					guninfoshow();
					saveachi_gun();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(0);
				}
				break;
			case 2:
				curpiece = MenuDataController.instance.Getpiece(gunmissiledata[shownum].id);
				if (MenuPlayerprefs.instance.DecPiece(curpiece.id, gunmissiledata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.savepieceflag(curpiece.id);
					if (curtype == weapontype.gun)
					{
						MenuPlayerprefs.instance.save_weapon_gun(shownum, CurweaponLockinfo[shownum]);
					}
					else if (curtype == weapontype.longrange)
					{
						MenuPlayerprefs.instance.save_weapon_long(shownum, CurweaponLockinfo[shownum]);
					}
					else
					{
						MenuPlayerprefs.instance.save_weapon_multiple(shownum, CurweaponLockinfo[shownum]);
					}
					scrolllock[shownum].enabled = false;
					guninfoshow();
					saveachi_gun();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
					MenuUIController.instance.enable_getpieceui(curpiece);
				}
				break;
		}
	}

	public void saveachi_gun()
	{
		switch (curtype)
		{
			case weapontype.gun:
				MenuPlayerprefs.instance.saveitemachi(3, 1);
				break;
			case weapontype.longrange:
				MenuPlayerprefs.instance.saveitemachi(4, 1);
				break;
			case weapontype.multiple:
				MenuPlayerprefs.instance.saveitemachi(5, 1);
				break;
		}
	}

	public void armourunlock()
	{
		switch (armourdata[shownum].unlocktype)
		{
			case 0:
				if (MenuPlayerprefs.instance.DecDiamond(armourdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.save_weapon_armour(shownum, CurweaponLockinfo[shownum]);
					scrolllock[shownum].enabled = false;
					armourinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(1);
				}
				break;
			case 1:
				if (MenuPlayerprefs.instance.DecMoney(armourdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.save_weapon_armour(shownum, CurweaponLockinfo[shownum]);
					scrolllock[shownum].enabled = false;
					armourinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
					MenuUIController.instance.enable_chargeui(0);
				}
				break;
			case 2:
				curpiece = MenuDataController.instance.Getpiece(armourdata[shownum].id);
				if (MenuPlayerprefs.instance.DecPiece(curpiece.id, armourdata[shownum].unlocknum))
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_BUY, 0f);
					CurweaponLockinfo[shownum].islock = 0;
					MenuPlayerprefs.instance.savepieceflag(curpiece.id);
					MenuPlayerprefs.instance.save_weapon_armour(shownum, CurweaponLockinfo[shownum]);
					scrolllock[shownum].enabled = false;
					armourinfoshow();
					OnClickequipedBtn(null);
				}
				else
				{
					MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
					MenuUIController.instance.enable_getpieceui(curpiece);
				}
				break;
		}
	}

	public void OnClickpiecebtn(GameObject btn)
	{
		if (curtype == weapontype.armour)
		{
			if (armourdata[shownum].unlocktype == 2)
			{
				MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
				MenuUIController.instance.enable_getpieceui(curpiece);
			}
		}
		else if (curtype == weapontype.miss)
		{
			if (YDDdata[shownum].unlocktype == 2)
			{
				MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
				MenuUIController.instance.enable_getpieceui(curpiece);
			}
		}
		else if (gunmissiledata[shownum].unlocktype == 2)
		{
			MonoInstance<AudioController>.instance.play(AudioType.UI_pophit, 0f);
			MenuUIController.instance.enable_getpieceui(curpiece);
		}
	}

	public void OnClickleftBtn(GameObject btn)
	{
		if (!scrollmoveflag && planescroll.value != 0f)
		{
			scrollmoveflag = true;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
			starttime = Time.time;
			intaltime = 0.5f;
			scrollrate = (0f - scrollstep) / intaltime;
			endval = planescroll.value - scrollstep;
			if (planescroll.value < scrollstep)
			{
				intaltime = planescroll.value / scrollstep * intaltime;
				endval = 0f;
			}
		}
	}

	public void OnClickrightBtn(GameObject btn)
	{
		if (!scrollmoveflag && planescroll.value != 1f)
		{
			scrollmoveflag = true;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN1, 0f);
			starttime = Time.time;
			intaltime = 0.5f;
			scrollrate = scrollstep / intaltime;
			endval = planescroll.value + scrollstep;
			if (1f - planescroll.value < scrollstep)
			{
				intaltime = (1f - planescroll.value) / scrollstep * intaltime;
				endval = 1f;
			}
		}
	}

	public void ChangeScroll()
	{
		if (planescroll.value < 0.01f)
		{
			leftflag.enabled = false;
		}
		else
		{
			leftflag.enabled = true;
		}
		if (planescroll.value > 0.99f)
		{
			rightflag.enabled = false;
		}
		else
		{
			rightflag.enabled = true;
		}
	}

	public void onclickitemBtn(GameObject btn)
	{
		int num = 0;
		while (true)
		{
			if (num < 10)
			{
				if (btn.name.Equals("item" + (num + 1)))
				{
					break;
				}
				num++;
				continue;
			}
			return;
		}
		shownum = num;
		itemfun();
	}

	public void itemfun()
	{
		if (preshow != shownum)
		{
			preshow = shownum;
			MonoInstance<AudioController>.instance.play(AudioType.UI_BTN, 0f);
			switch (curtype)
			{
				case weapontype.armour:
					armourinfoshow();
					break;
				case weapontype.gun:
					guninfoshow();
					break;
				case weapontype.longrange:
					guninfoshow();
					break;
				case weapontype.multiple:
					guninfoshow();
					break;
				case weapontype.miss:
					missinfoshow();
					break;
			}
		}
	}

	public void enable(int num)
	{
		CurPlane = num;
		init_ui_info();
	}

	public void OnClickOnSaleBtn(GameObject btn)
	{
		MenuUIController.instance.AutoSaleui();
	}
}
